var ax = { 
    post: function (c) {  
        loginFilter();
        var config = {
            headers: this.getHeaders(),
            type: "POST",
            contentType: "application/json",
            dataType: "json",
            autoPrefix: true
        };

        this.copyPro(config, c);

        layui.jquery.ajax(config);
    },
    get: function (c) { 
        loginFilter();

        var config = {
            headers: this.getHeaders(),
            type: "GET",
            contentType: "application/x-www-form-urlencoded",
            dataType: "json",
            autoPrefix: true
        };
        this.copyPro(config, c);

        layui.jquery.ajax(config);
    },
    VTable: function (c) { 
        loginFilter();
        var config = {
            method: "GET",
            autoPrefix: true,
            headers: this.getHeaders(),
            request: {
                pageName: 'pageIndex'
                , limitName: 'pageSize'
            },
            parseData: this.parseTableData,
            page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
                , groups: 5 //只显示 1 个连续页码
                , first: false  //不显示首页
                , last: false //不显示尾页
                , limit: 10  //每页显示的条数
                , page: 1   //第几页
                , limits: [5, 10, 20, 30, 50]

            }
        };
        this.copyPro(config, c);

        return layui.table.render(config);
    },    
    upload: function (c) { 
        var config = {  
            headers: this.getHeaders(),
            data:{appId:SystemId}
        };
        this.copyPro(config, c);

        return  layui.upload.render(config);
    },
    getParamStr: function () {
        return "currentUserId="+getCookie(currentUserId)+"&appId="+SystemId;
    },
    copyPro: function (target, from) {
        if (target && from) {
            var fn;
            for (fn in from) {
                target[fn] = from[fn];
            }
        }
    },
    parseTableData: function (res) {
        return {
            "code": res.code,
            "msg": res.message,
            "count": res.data.total,
            "data": res.data.records
        };
    },
    getHeaders: function () {
        return { currentUserId: getCookie(currentUserId) ,Authorization: "Bearer"+getCookie(gatewayAuthorization)};
    },
    dateInit:function(c) {
        $(c).val($(c).attr("df"));
        $(c).attr("placeholder","yyyy-MM-dd");
        layui.laydate.render({ elem: c, type: 'date' });
    },
    dateTimeInit:function(c) {
        $(c).val($(c).attr("df"));
        $(c).attr("placeholder","yyyy-MM-dd HH:mm:ss");
        layui.laydate.render({ elem: c, type: 'datetime' });
    }
}
